package com.jinlejia.bbs.logic;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;
import com.jinlejia.bbs.http.utils.BBSConfig;
import com.jinlejia.bbs.http.utils.HttpCallBack;
import com.jinlejia.bbs.http.utils.HttpUtils;

import static com.jinlejia.bbs.http.utils.HttpUtils.*;
/**
 * @author 王进 on 2019/4/11.
 */
//邀请回答
public class InviterecordLogic {
    private Context context;
    public InviterecordLogic(Context context){
        this.context = context;
    }

    public void execute(String pin, String userName, String topicCode, final LogicCallBack callBack){
        JSONObject json = new JSONObject();
        json.put("bePin",pin);
        json.put("beName",userName);
        json.put("topicCode",topicCode);
        httpCallForm(BBSConfig.saveInviterecord,json).execute(httpCallBack(context, new HttpCallBack() {
            @Override
            public void onError(Exception e) {
                callBack.onResult(false);
            }

            @Override
            public void onResponse(JsonParse parse) {
                boolean result = parse.parse(Boolean.class);
                callBack.onResult(result);
            }

            @Override
            public void onNoResponse(int code) {
                callBack.onResult(false);
            }
        }));
    }


    public interface LogicCallBack{
        void onResult(boolean result);
    }
}
